{% extends "base.html" %}

{% block title %}Flasky - {{ user.username }}{% endblock %}

{% block page_content %}
<div class="page-header">
    <img class="img-rounded profile-thumbnail" src="{{ user.gravatar(size=256) }}">
    <div class="profile-header">
        <h1>{{ user.username }}</h1>
        {% if user.name or user.location %}
        <p>
            名字：{% if user.name %}{{ user.name }}<br>{% endif %}
            {% if user.location %}
                所在地： <a href="http://www.amap.com/search?query={{ user.location }}">
                    {{ user.location }}
                </a><br>
            {% endif %}
        </p>
        {% endif %}
        {% if current_user.is_administrator() %}
        <p><strong>邮箱：</strong><a href="mailto:{{ user.email }}">{{ user.email }}</a></p>
        {% endif %}

        <hr />
        <p>个人简介：</p>
        <p>{% if user.about_me %}<p>{{user.about_me}}</p>{% endif %}</p>
        <hr />
        <p>
            <strong>注册于：</strong>{{ moment(user.member_since).format('L')}} &nbsp;&nbsp;&nbsp;
            <strong>最后在线：</strong> {{ moment(user.last_seen).fromNow() }}
        </p>
        <p>ta的文章数量：{{ user.posts.count() }}  &nbsp;&nbsp;&nbsp; ta发表的评论数：{{user.comments.count() }}</p>
        <p>
            <p>
                {% if current_user.can(Permission.FOLLOW) and user != current_user %}
                    {% if not current_user.is_following(user) %}
                    <a href="{{ url_for('.follow', username=user.username) }}" class="btn btn-primary">关注</a>
                    {% else %}
                    <a href="{{ url_for('.unfollow', username=user.username) }}" class="btn btn-warning">取关</a>
                    {% endif %}
                {% endif %}
                <a href="{{ url_for('.followers', username=user.username) }}">ta的粉丝: <span class="badge">{{ user.followers.count() - 1 }}</span></a>
                &nbsp;&nbsp;&nbsp;
                <a href="{{ url_for('.followed_by', username=user.username) }}">ta的关注: <span class="badge">{{ user.followed.count() - 1}}</span></a>
                {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %}
                | <span class="label label-default">Follows you</span>
                {% endif %}
            </p>
        <p>
            {% if user == current_user %}
            <a class="btn btn-default" href="{{ url_for('.edit_profile') }}" >编辑个人资料</a>
            {% endif %}
            {% if current_user.is_administrator() %}
            <a class="btn btn-danger" href="{{ url_for('.edit_profile_admin', id=user.id)}}">编辑个人资料 [管理员]</a>
            {% endif %}
        </p>
    </div>
</div>
<h3>{{ user.username }} 的文章：</h3>
{% include '_posts.html' %}
{% endblock %}
